package thinkingJava.chapter11;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.TreeSet;

import thinkingJava.chapter14.Pet;
import thinkingJava.chapter14.Pets;

public class CrossContainerIteration {
	public static void display(Iterator<Pet> it) {
		while(it.hasNext()) {
			Pet p = it.next();
			System.out.println(p.id() + " : " + p + "    ==|");
		}
	}
	public static void main(String[] args) {
		ArrayList<Pet> pets = Pets.arrayList(8);
		LinkedList<Pet> petsll = new LinkedList<Pet>(pets);

		HashSet<Pet> petshs = new HashSet<Pet>(pets);
		TreeSet<Pet> petsts = new TreeSet<Pet>(pets);

		display(pets.iterator());
		display(petsll.iterator());
		display(petshs.iterator());
		display(petsts.iterator());
	}
}
